home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / CPP / WFC010.ZIP / TEST / TCTAPE.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-13  |  10.7 KB  |  389 lines

  1. #include "test.h"
  2. #pragma hdrstop
  3.  
  4. void list_features( DWORD low, DWORD high );
  5.  
  6. void test_CTape( UINT tape_drive_number_to_test )
  7. {
  8.    CTape tape;
  9.  
  10.    if ( tape.Open( tape_drive_number_to_test ) != TRUE )
  11.    {
  12.       TRACE( "Can't open TAPE%u because\n", tape_drive_number_to_test );
  13.       ReportError( tape.GetError() );
  14.       return;
  15.    }
  16.    else
  17.    {
  18.       TRACE( "Tape opened\n" );
  19.    }
  20.  
  21.    if ( tape.Lock() != TRUE )
  22.    {
  23.       TRACE( "Can't Lock TAPE%u because\n", tape_drive_number_to_test );
  24.       ReportError( tape.GetError() );
  25.       return;
  26.    }
  27.    else
  28.    {
  29.       TRACE( "Tape locked\n" );
  30.    }
  31.  
  32.    if ( tape.Load() != TRUE )
  33.    {
  34.       TRACE( "Can't Load TAPE%u because\n", tape_drive_number_to_test );
  35.       ReportError( tape.GetError() );
  36.       return;
  37.    }
  38.    else
  39.    {
  40.       TRACE( "Tape loaded\n" );
  41.    }
  42.  
  43.    CTapeGetDriveParameters drive_parameters;
  44.  
  45.    if ( tape.GetParameters( drive_parameters ) != TRUE )
  46.    {
  47.       TRACE( "Can't get drive parameters TAPE%u\n", tape_drive_number_to_test );
  48.       ReportError( tape.GetError() );
  49.       return;
  50.    }
  51.  
  52.    TRACE( "Drive Parameters:\n" );
  53.    TRACE( "  ECC                   = %s\n", ( ( drive_parameters.ECC            == TRUE ) ? "True" : "False" ) );
  54.    TRACE( "  Compression           = %s\n", ( ( drive_parameters.Compression    == TRUE ) ? "True" : "False" ) );
  55.    TRACE( "  DataPadding           = %s\n", ( ( drive_parameters.DataPadding    == TRUE ) ? "True" : "False" ) );
  56.    TRACE( "  ReportSetmarks        = %s\n", ( ( drive_parameters.ReportSetmarks == TRUE ) ? "True" : "False" ) );
  57.    TRACE( "  DefaultBlockSize      = %ld\n", drive_parameters.DefaultBlockSize );
  58.    TRACE( "  MaximumBlockSize      = %ld\n", drive_parameters.MaximumBlockSize );
  59.    TRACE( "  MinimumBlockSize      = %ld\n", drive_parameters.MinimumBlockSize );
  60.    TRACE( "  MaximumPartitionCount = %ld\n", drive_parameters.MaximumPartitionCount );
  61.    TRACE( "  FeaturesLow           = %lX\n", drive_parameters.FeaturesLow );
  62.    TRACE( "  FeaturesHigh          = %lX\n", drive_parameters.FeaturesHigh );
  63.    TRACE( "  EOTWarningZoneSize    = %ld\n", drive_parameters.EOTWarningZoneSize );
  64.  
  65.    list_features( drive_parameters.FeaturesLow, drive_parameters.FeaturesHigh );
  66.  
  67.    /*
  68.    ** Lock the tape
  69.    */
  70.  
  71.    BYTE buffer[ 256 ];
  72.  
  73.    ZeroMemory( buffer, sizeof( buffer ) );
  74.  
  75.    DWORD number_of_bytes_read = 0;
  76.  
  77.    if ( ReadFile( (HANDLE) tape.m_hFile, buffer, sizeof( buffer ), &number_of_bytes_read, NULL ) != TRUE )
  78.    {
  79.       TRACE( "Can't ReadFile TAPE%u\n", tape_drive_number_to_test );
  80.       ReportError( GetLastError() );
  81.    }
  82.    else
  83.    {
  84.       DWORD index = 0;
  85.  
  86.       while( index < number_of_bytes_read )
  87.       {
  88.          TRACE( "%03d - %02X - %c\n", index, (int) buffer[ index ], (char) buffer[ index ] );
  89.          index++;
  90.       }
  91.    }
  92.  
  93.    CTapeGetMediaParameters media_parameters;
  94.  
  95.    if ( tape.GetParameters( media_parameters ) != TRUE )
  96.    {
  97.       TRACE( "Can't get media parameters TAPE%u\n", tape_drive_number_to_test );
  98.       ReportError( tape.GetError() );
  99.       return;
  100.    }
  101.    else
  102.    {
  103.       TRACE( "Media Parameters:\n" );
  104.       TRACE( "  Capacity.Low   = %lu\n", media_parameters.Capacity.LowPart   );
  105.       TRACE( "  Capacity.High  = %lu\n", media_parameters.Capacity.HighPart  );
  106.       TRACE( "  Remaining.Low  = %lu\n", media_parameters.Remaining.LowPart  );
  107.       TRACE( "  Remaining.High = %lu\n", media_parameters.Remaining.HighPart );
  108.       TRACE( "  PartitionCount = %lu\n", media_parameters.PartitionCount     );
  109.       TRACE( "  WriteProtected = %s\n", ( ( media_parameters.WriteProtected == TRUE ) ? "True" : "False" ) );
  110.    }
  111.  
  112.    if ( tape.Unlock() != TRUE )
  113.    {
  114.       TRACE( "Can't Unlock TAPE%u because\n", tape_drive_number_to_test );
  115.       ReportError( tape.GetError() );
  116.       return;
  117.    }
  118.    else
  119.    {
  120.       TRACE( "Tape unlocked\n" );
  121.    }
  122.  
  123.    if ( tape.Unload() != TRUE )
  124.    {
  125.       TRACE( "Can't Unload TAPE%u because\n", tape_drive_number_to_test );
  126.       ReportError( tape.GetError() );
  127.       return;
  128.    }
  129.    else
  130.    {
  131.       TRACE( "Tape unloaded\n" );
  132.    }
  133.  
  134.    tape.Close();
  135. }
  136.  
  137. void list_features( DWORD low, DWORD high )
  138. {
  139.    if ( low & TAPE_DRIVE_COMPRESSION )
  140.    {
  141.       TRACE( "Device supports hardware data compression.\n" );
  142.    }
  143.  
  144.    if ( low & TAPE_DRIVE_ECC )
  145.    {
  146.       TRACE( "Device supports hardware error correction.\n" );
  147.    }
  148.  
  149.    if ( low & TAPE_DRIVE_ERASE_BOP_ONLY )
  150.    {
  151.       TRACE( "Device performs the erase operation from the beginning-of-partition marker only.\n" );
  152.    }
  153.  
  154.    if ( low & TAPE_DRIVE_ERASE_LONG )
  155.    {
  156.       TRACE( "Device performs a long erase operation.\n" );
  157.    }
  158.  
  159.    if ( low & TAPE_DRIVE_ERASE_IMMEDIATE )
  160.    {
  161.       TRACE( "Device performs an immediate erase operation that is, it returns when the erase operation begins.\n" );
  162.    }
  163.  
  164.    if ( low & TAPE_DRIVE_ERASE_SHORT )
  165.    {
  166.       TRACE( "Device performs a short erase operation.\n" );
  167.    }
  168.  
  169.    if ( low & TAPE_DRIVE_FIXED )
  170.    {
  171.       TRACE( "Device creates fixed data partitions.\n" );
  172.    }
  173.  
  174.    if ( low & TAPE_DRIVE_FIXED_BLOCK )
  175.    {
  176.       TRACE( "Device supports fixed-length block mode.\n" );
  177.    }
  178.  
  179.    if ( low & TAPE_DRIVE_INITIATOR )
  180.    {
  181.       TRACE( "Device creates initiator-defined partitions.\n" );
  182.    }
  183.  
  184.    if ( low & TAPE_DRIVE_PADDING )
  185.    {
  186.       TRACE( "Device supports data padding.\n" );
  187.    }
  188.  
  189.    if ( low & TAPE_DRIVE_GET_ABSOLUTE_BLK )
  190.    {
  191.       TRACE( "Device provides the current device-specific block address.\n" );
  192.    }
  193.  
  194.    if ( low & TAPE_DRIVE_GET_LOGICAL_BLK )
  195.    {
  196.       TRACE( "Device provides the current logical block address (and logical tape partition).\n" );
  197.    }
  198.  
  199.    if ( low & TAPE_DRIVE_REPORT_SMKS )
  200.    {
  201.       TRACE( "Device supports setmark reporting.\n" );
  202.    }
  203.  
  204.    if ( low & TAPE_DRIVE_SELECT )
  205.    {
  206.       TRACE( "Device creates select data partitions.\n" );
  207.    }
  208.  
  209.    if ( low & TAPE_DRIVE_SET_EOT_WZ_SIZE )
  210.    {
  211.       TRACE( "Device supports setting the end-of-medium warning size.\n" );
  212.    }
  213.  
  214.    if ( low & TAPE_DRIVE_TAPE_CAPACITY )
  215.    {
  216.       TRACE( "Device returns the maximum capacity of the tape.\n" );
  217.    }
  218.  
  219.    if ( low & TAPE_DRIVE_TAPE_REMAINING )
  220.    {
  221.       TRACE( "Device returns the remaining capacity of the tape.\n" );
  222.    }
  223.  
  224.    if ( low & TAPE_DRIVE_VARIABLE_BLOCK )
  225.    {
  226.       TRACE( "Device supports variable-length block mode.\n" );
  227.    }
  228.  
  229.    if ( low & TAPE_DRIVE_WRITE_PROTECT )
  230.    {
  231.       TRACE( "Device returns an error if the tape is write-enabled or write-protected.\n" );
  232.    }
  233.  
  234.    if ( high & TAPE_DRIVE_ABS_BLK_IMMED )
  235.    {
  236.       TRACE( "Device moves the tape to a device-specific block address and returns as soon as the move begins.\n" );
  237.    }
  238.  
  239.    if ( high & TAPE_DRIVE_ABSOLUTE_BLK )
  240.    {
  241.       TRACE( "Device moves the tape to a device specific block address.\n" );
  242.    }
  243.  
  244.    if ( high & TAPE_DRIVE_END_OF_DATA )
  245.    {
  246.       TRACE( "Device moves the tape to the end-of-data marker in a partition.\n" );
  247.    }
  248.  
  249.    if ( high & TAPE_DRIVE_FILEMARKS )
  250.    {
  251.       TRACE( "Device moves the tape forward (or backward) a specified number of filemarks.\n" );
  252.    }
  253.  
  254.    if ( high & TAPE_DRIVE_LOAD_UNLOAD )
  255.    {
  256.       TRACE( "Device enables and disables the device for further operations.\n" );
  257.    }
  258.  
  259.    if ( high & TAPE_DRIVE_LOAD_UNLD_IMMED )
  260.    {
  261.       TRACE( "Device supports immediate load and unload operations.\n" );
  262.    }
  263.  
  264.    if ( high & TAPE_DRIVE_LOCK_UNLOCK )
  265.    {
  266.       TRACE( "Device enables and disables the tape ejection mechanism.\n" );
  267.    }
  268.  
  269.    if ( high & TAPE_DRIVE_LOCK_UNLK_IMMED )
  270.    {
  271.       TRACE( "Device supports immediate lock and unlock operations.\n" );
  272.    }
  273.  
  274.    if ( high & TAPE_DRIVE_LOG_BLK_IMMED )
  275.    {
  276.       TRACE( "Device moves the tape to a logical block address in a partition and returns as soon as the move begins.\n" );
  277.    }
  278.  
  279.    if ( high & TAPE_DRIVE_LOGICAL_BLK )
  280.    {
  281.       TRACE( "Device moves the tape to a logical block address in a partition.\n" );
  282.    }
  283.  
  284.    if ( high & TAPE_DRIVE_RELATIVE_BLKS )
  285.    {
  286.       TRACE( "Device moves the tape forward (or backward) a specified number of blocks.\n" );
  287.    }
  288.  
  289.    if ( high & TAPE_DRIVE_REVERSE_POSITION )
  290.    {
  291.       TRACE( "Device moves the tape backward over blocks, filemarks, or setmarks.\n" );
  292.    }
  293.  
  294.    if ( high & TAPE_DRIVE_REWIND_IMMEDIATE )
  295.    {
  296.       TRACE( "Device supports immediate rewind operation.\n" );
  297.    }
  298.  
  299.    if ( high & TAPE_DRIVE_SEQUENTIAL_FMKS )
  300.    {
  301.       TRACE( "Device moves the tape forward (or backward) to the first occurrence of a specified number of consecutive filemarks.\n" );
  302.    }
  303.  
  304.    if ( high & TAPE_DRIVE_SEQUENTIAL_SMKS )
  305.    {
  306.       TRACE( "Device moves the tape forward (or backward) to the first occurrence of a specified number of consecutive setmarks.\n" );
  307.    }
  308.  
  309.    if ( high & TAPE_DRIVE_SET_BLOCK_SIZE )
  310.    {
  311.       TRACE( "Device supports setting the size of a fixed-length logical block or setting the variable-length block mode.\n" );
  312.    }
  313.  
  314.    if ( high & TAPE_DRIVE_SET_COMPRESSION )
  315.    {
  316.       TRACE( "Device enables and disables hardware data compression.\n" );
  317.    }
  318.  
  319.    if ( high & TAPE_DRIVE_SET_ECC )
  320.    {
  321.       TRACE( "Device enables and disables hardware error correction.\n" );
  322.    }
  323.  
  324.    if ( high & TAPE_DRIVE_SET_PADDING )
  325.    {
  326.       TRACE( "Device enables and disables data padding.\n" );
  327.    }
  328.  
  329.    if ( high & TAPE_DRIVE_SET_REPORT_SMKS )
  330.    {
  331.       TRACE( "Device enables and disables the reporting of setmarks.\n" );
  332.    }
  333.  
  334.    if ( high & TAPE_DRIVE_SETMARKS )
  335.    {
  336.       TRACE( "Device moves the tape forward (or reverse) a specified number of setmarks.\n" );
  337.    }
  338.  
  339.    if ( high & TAPE_DRIVE_SPACE_IMMEDIATE )
  340.    {
  341.       TRACE( "Device supports immediate spacing.\n" );
  342.    }
  343.  
  344.    if ( high & TAPE_DRIVE_TENSION )
  345.    {
  346.       TRACE( "Device supports tape tensioning.\n" );
  347.    }
  348.  
  349.    if ( high & TAPE_DRIVE_TENSION_IMMED )
  350.    {
  351.       TRACE( "Device supports immediate tape tensioning.\n" );
  352.    }
  353.  
  354.    if ( high & TAPE_DRIVE_WRITE_FILEMARKS )
  355.    {
  356.       TRACE( "Device writes filemarks.\n" );
  357.    }
  358.  
  359.    if ( high & TAPE_DRIVE_WRITE_LONG_FMKS )
  360.    {
  361.       TRACE( "Device writes long filemarks.\n" );
  362.    }
  363.  
  364.    if ( high & TAPE_DRIVE_WRITE_MARK_IMMED )
  365.    {
  366.       TRACE( "Device supports immediate writing of short and long filemarks.\n" );
  367.    }
  368.  
  369.    if ( high & TAPE_DRIVE_WRITE_SETMARKS )
  370.    {
  371.       TRACE( "Device writes setmarks.\n" );
  372.    }
  373.  
  374.    if ( high & TAPE_DRIVE_WRITE_SHORT_FMKS )
  375.    {
  376.       TRACE( "Device writes short filemarks.\n" );
  377.    }
  378.  
  379.    if ( high & TAPE_DRIVE_FORMAT )
  380.    {
  381.       TRACE( "TAPE_DRIVE_FORMAT\n" );
  382.    }
  383.  
  384.    if ( high & TAPE_DRIVE_FORMAT_IMMEDIATE )
  385.    {
  386.       TRACE( "TAPE_DRIVE_FORMAT_IMMEDIATE\n" );
  387.    }
  388. }
  389.